package com.example.core.controller;


import com.example.core.arch.baseData.CodeConstants;
import com.example.core.arch.exception.VerifyException;
import com.example.core.arch.response.BaseResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;

@Slf4j
public abstract class BaseController {


    @ExceptionHandler(VerifyException.class)
    public <T> BaseResponse<T> fail(VerifyException exception) {
        exception.printStackTrace();
        return BaseResponse.fail(exception.getErrorMessage());
    }


    @ExceptionHandler
    public <T> BaseResponse<T> fail(Exception exception) {
        exception.printStackTrace();
        return BaseResponse.fail(CodeConstants.COMMON_FAIL);
    }
}
